<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // aabccd统计每个字符出现的次数，去掉重复的字符，使结果显示 abcd
      //   var a = "aabccd";

      //   var b = [];

      //   for (i = 0; i < a.length; i++) {
      //     if (b.indexOf(a[i]) == -1) {
      //       b.push(a[i]);
      //     }
      //   }
      //   var c = b.join("");
      //   console.log(c);
      // 反转字符串
      var str = "abcdefg";
      var a = [];
      for (i = 0; i < str.length; i++) {
        a.push(str[i]);
      }

      a.reverse();
      console.log(a);
      var res = a.join("");
      console.log(res);
    </script>
  </body>
</html>
